<?php
namespace app\home\model;

use think\Model;

class Charge extends Model
{
   protected $table = 'rd_home_charge';
    /**
     * 显示列表.
     *
     * @return \think\Response
     */
    public  function lists($data){
        //
        $where['role'] = $data['role'];
        $lists = User::where($where)
            ->order('create_time desc')
            ->paginate($data['listrow']);
       if (!empty($lists)){
           return $lists;
       }else{
           return false;
       }
    }
    /**
     * 保存新建的贷款口子内容
     * @param $data 数据
     * @return \think\Response
     */
    public function addCharges($data){
        //拼接数据
        if (empty($data)){
            return false;
        }

        $insert['name'] = $data['name'];
        $insert['count'] = $data['count'];
        $insert['price'] = $data['price'];
        $insert['create_time'] = time();
        //插入到数据库中
        $result = Charge::insert($insert);
        if ($result){
            return true;
        }else{
            return false;
        }
    }
}